package com.punch.course.controller;

import com.punch.common.vo.order.StudentCourseClassVO;
import com.punch.course.service.StudentCourseScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(value = "StudentCourseScheduleController", tags = "学生课表Controller")
public class StudentCourseScheduleController {

    @Resource
    private StudentCourseScheduleService studentCourseScheduleService;


    /**
     * 保存学生课表
     *
     * @param classId              课程id
     * @param studentCourseClassVO 学生信息
     * @return long
     */
    @PostMapping(value = "/course-schedule/{classId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "保存学生课表", notes = "保存学生课表", produces = "application/json")
    public Long saveStudentCourseSchedule(@PathVariable("classId") Long classId, @RequestBody StudentCourseClassVO studentCourseClassVO) {
        return studentCourseScheduleService.saveStudentCourseSchedule(classId, studentCourseClassVO);
    }


    /**
     * 获取学生当前学期出勤率
     *
     * @param studentId 学生id
     * @param areaId    地区id,用于查询学期
     * @return double
     */
    @GetMapping(value = "/course-schedule/attendance-rate/{studentId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "获取学生当前学期出勤率", notes = "获取学生当前学期出勤率", produces = "application/json")
    public Double attendanceRate(@PathVariable("studentId") Long studentId, @RequestParam(name = "areaId") Integer areaId) {
        return studentCourseScheduleService.attendanceRate(studentId, areaId);
    }
}
